Part Number Hot Search : 
S29BDS AD7920 06C10 LV49152V KBP00 P101KW AD9237 GS1084
Product Description
Full Text Search
 

To Download AN3126 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  april 2015 doc id16895 rev 2 1/24 1 AN3126 application note audio and waveform generation using the dac in stm32 microcontrollers introduction this application note provides some exampl es for generating audio waveforms using the digital to analog converter (dac) peripheral embedded in the microcontrollers of the stm32fx and stm32lx series. this document applies to products listed in table 1 , and should be read in connection with application note an4566 ?extending the dac performance of stm32 microcontrollers?. a digital to analog converter, dac, is a device that has the opposite f unction to that of an analog to digital converter, i.e. it converts a digital word to a corresponding analog voltage. the stm32 dac module is a 12-bit word converter, with up to three output channels to support audio functions. the dac can be used in many audio applicat ions such as security alarms, bluetooth headsets, talking toys, answering machines, man-machine interfaces, and low-cost music players stm32 dac can also be used for many other analog purposes, such as analog waveform generation and control engineering. the application note is organized in two main sections: ? section 1 describes the main features of the stm32 dac module. ? section 2 presents two examples. ? in the first example, the dac is used to generate a sine wavefom. ? in the second example, the dac is used to generate audio from .wav files. table 1. applicable products type product series microcontrollers stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32l0 stm32l1 stm32l4 www.st.com
contents AN3126 2/24 doc id16895 rev 2 contents 1 dac main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3 dual channel mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4 dedicated timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.5 dma capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.6 dma underrun error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.7 white noise generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.7.1 definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.7.2 typical applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.8 triangular wave generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 1.8.1 definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.8.2 typical applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.9 buffered output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2 application examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.1 using the dac to generate a sine waveform . . . . . . . . . . . . . . . . . . . . . . 15 2.1.1 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.1.2 digital sine waveform pattern preparation . . . . . . . . . . . . . . . . . . . . . . . 15 2.1.3 fixing the sine wave frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2 using the dac to implement an audio wave player . . . . . . . . . . . . . . . . . 18 2.2.1 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2.2 audio wave file specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.2.3 .wav file format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.3 audio wave player implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3 conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
doc id16895 rev 2 3/24 AN3126 list of tables 3 list of tables table 1. applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 table 2. dac configurations for stm32 microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 table 3. preprogrammable triangular waveform amplitude values . . . . . . . . . . . . . . . . . . . . . . . . . . 12 table 4. digital and analog sample values of the sine wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 table 5. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
list of figures AN3126 4/24 doc id16895 rev 2 list of figures figure 1. dac data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 figure 2. stm32f100x dac trigger channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 figure 3. dac interaction without dma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 figure 4. dac interaction with dma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 figure 5. pseudo random code generator embedded in the da c . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 figure 6. noise waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 figure 7. noise waveform with changeable offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 figure 8. triangular wave form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 figure 9. triangular waveform with changeab le offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 10. non buffered channel voltage (with and without load ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 11. buffered channel voltage (with and without load) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 12. sine wave model samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 13. sine wave generated with ns = 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 figure 14. sine wave generated with ns = 255 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 figure 15. flow of data from microsd flash memory to ex ternal speakers . . . . . . . . . . . . . . . . . . . . 18 figure 16. wave player flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 figure 17. cpu and dma activities during wave playing proces s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
doc id16895 rev 2 5/24 AN3126 dac main features 23 1 dac main features 1.1 overview stm32 microcontrollers integrate dac with different configurations and features: ? 1 to 3 dac output channels ? noise waveform generation ? triangular waveform generation ? dma under run flag ? dedicated analog clock table 2 summarizes the different stm32 dac configuration. table 2. dac configurations for stm32 microcontrollers series product rpn dac outputs white noise generator triangular wave generator dma capability dma underrun error f0 stm32f030xx stm32f031xx stm32f038xx stm32f042xx stm32f048xx stm32f070xx 0- - -- stm32f051xx stm32f058xx 1no noyesno stm32f071xx stm32f072xx stm32f078xx stm32f091xx stm32f098xx 2 yes yes yes yes f1 stm32f101x4/6/8b stm32f102xx stm32f103x4/6/8b 0- - -- stm32f100xx stm32f101xc/d/e/f/g stm32f103xc/d/e/f/g stm32f105xx stm32f107xx 2 yes yes yes yes f2 stm32f2xxxx 2 yes yes yes yes
dac main features AN3126 6/24 doc id16895 rev 2 f3 stm32f301xx stm32f302xx stm32f318xx 1 yes yes yes yes stm32f303xb/c/d/e stm32f358xx stm32f398xx 2 yes yes yes yes stm32f3328 stm32f3334 stm32f3373 stm32f3378 3 yes (only for 2 channels) yes (only for 2 channels) yes yes f4 stm32f401xx stm32f411xx 0- - -- stm32f405xx stm32f407xx stm32f415xx stm32f417xx stm32f427xx stm32f429xx stm32f437xx stm32f439xx stm32f446xx 2 yes yes yes yes f7 stm32f7xxxx 2 yes yes yes yes l0 stm32l031xx stm32l041xx stm32l051xx stm32l071xx stm32l081xx 0- - -- stm32l052xx stm32l053xx stm32l062xx stm32l063xx 1 yes yes yes yes l1 stm32l1xxxx 2 yes yes yes yes l4 stm32l4xxxx 2 yes yes yes yes table 2. dac configurations for stm32 microcontrollers (continued) series product rpn dac outputs white noise generator triangular wave generator dma capability dma underrun error
doc id16895 rev 2 7/24 AN3126 dac main features 23 1.2 data format the dac accepts data in 3 integer formats: 8-bit, 12-bit right aligned and 12-bit left aligned. a 12-bit value can range from 0x000 to 0x fff, with 0x000 being the lowest and 0xfff being the highest value. figure 1. dac data format 1.3 dual channel mode note: this feature is supported only for products that embed at least 2 dacs. the dac has two output channels, each with it s own converter. in dual dac channel mode, conversions could be done independently or simultaneously. when the dac channels are triggered by the same source, both channels are grouped together for synchronous update operations and conversions are done simultaneously. 1.4 dedicated timers in addition to the software and external triggers, the dac conversion can be triggered by different timers. tim6 and tim7 are basic timers and are basically designed for dac triggering. each time a dac interface detects a rising edge on the selected timer trigger output (timx_trgo), the last data stored in the dac_dhrx register is transferred to the dac_dorx register (an example for stm32f100x is given in figure 2 ). ai18300
dac main features AN3126 8/24 doc id16895 rev 2 figure 2. stm32f100x dac trigger channels 1.5 dma capabilities the stm32 microcontrollers have a dma module with multiple channels. each dac channel is connected to an independent dma channel. in the case of stm32f100x microcontrollers, the dac channel 1 is connec ted to the dma channel 3 and dac channel2 is connected to dma channel 4. when dma is not utilized, t he cpu is used to provide da c with the pattern waveform. generally the waveform is saved in a memory (ram), and the cpu is in charge of transferring the data from ram to the dac. figure 3. dac interaction without dma 069 '$&&kdqqhob[7uljjhu 76(/[>@elwv 7,0b75*2 7,0b75*2 7,0b75*2 7,0b75*2 7,0b75*2 7,0b75*2 6:75,*[ (;7,b ai18302 dac ram (pattern table 1) (pattern table 2) channel 1 output channel 2 output dac triggers cpu
doc id16895 rev 2 9/24 AN3126 dac main features 23 when using the dma, the overall performance of the system is increased by freeing up the core. this is because data is moved from memory to dac by dma, without needing any actions by the cpu. this keeps cpu resources free for other operations. figure 4. dac interaction with dma 1.6 dma underrun error when the dma is used to provide dac with the pattern wave form, there are some cases where the dma transfer is faster than the dac conversion, in this case, dac detects that a part of the pattern waveform has been ignored and was not converted. it then sets the "dma underrun error" flag. the underrun error can be handled using a shar ed irq channel with the triggering timer or by a dedicated interrupt when dac is not triggered by tim6. 1.7 white noise generator 1.7.1 definition the stm32 microcontrollers dac provides user with a pseudo random code generator, sketched in figure 5 . depending on what taps are used on the shift register, a sequence of up to 2 n-1 numbers can be generated before the sequence repeats. ai18303 dac dma ram (pattern table 1) (pattern table 2) channel 1 output channel 2 output dac triggers cpu
dac main features AN3126 10/24 doc id16895 rev 2 figure 5. pseudo random code generator embedded in the dac the noise produced by this generator has a flat spectral distribution and can be considered white noise. however, instead of having a gau ssian output characterist ics, it is uniformly distributed, see figure 6 . figure 6. noise waveform the offset of the noise waveform is programmable. by varying this offset using a preconfigured table of offsets (signal pattern), user can obtain a waveform which correspond to the sum of the signal pa ttern and the noise waveform. 069              [  [  [  [[ 
doc id16895 rev 2 11/24 AN3126 dac main features 23 figure 7. noise waveform with changeable offset 1.7.2 typical applications the stm32 microcontrollers come with 12-bit enhanced adc with a sampling rate of up to 1 m samples/s. in most applicat ions, this resolution is suffic ient, but in some cases where higher accuracy is required, the concept of oversampling and decimating the input signal can be implemented to save the use of an external adc solution and to reduce the application power consumption. more details about these methods are explai ned in the application note an2668, in the section titled ?oversamp ling using white noise?. white noise generator can be also used in the production of electronic music, usually either directly or as an input for a filter to create othe r types of noise signal. it is used extensively in audio synthesis, typically to recreate percussi ve instruments such as cymbals which have high noise content in their frequency domain. white noise generator can be used for contro l engineering purposes, it can be used for frequency response testing of amplifiers and electronic filters. white noise is a common synthetic noise so urce used for sound masking by a tinnitus masker. 1.8 triangular wave generator 1.8.1 definition the stm32 dac provides the user with a tri angular waveform generator with a flexible offset, amplitude and frequency. theoretically, a triangular wave form is a wave form comprise d of an infinite set of odd harmonic sine waves (see figure 9 ). the amplitude of the triangular waveform can be fixed using the mampx bits in the dac_cr register. ai18306 noise waveform pattern waveform (offset) result waveform
dac main features AN3126 12/24 doc id16895 rev 2 for more details about the triangular waveform, please read the dedicated sections in the reference manuals of the stm32 products. the triangular waveform frequency is related to the frequency of the trigger source. figure 8. triangular waveform the offset of the triangular waveform is programmable (see figure 9 ). by varying the offset of the triangular waveform with a preconfigur ed table of offsets (signal pattern), user can obtain a waveform which corresponds to the sum of the signal pattern and the triangular waveform. table 3. preprogrammable triangular waveform amplitude values mampx[3:0] bits digital amplitude analog amplitude (volt) (with vref+ = 3.3v) 0 1 0.0016 1 3 0.0032 2 7 0.0064 3 15 0.0128 4 31 0.0257 5 63 0.0515 6 127 0.1031 7 255 0.2062 8 511 0.4125 9 1023 0.8250 10 2045 1.6483 11 4095 3.3000 ai18307 3.3v time dac output x voltage 0v offset frequency amplitude
doc id16895 rev 2 13/24 AN3126 dac main features 23 figure 9. triangular waveform with changeable offset 1.8.2 typical applications triangular wave generators are often used in sound synthesis as its timbre is less harsh than the square wave because the amplitude of its upper harmonics falls off more rapidly. triangular wave generator circuits are also used in many modem circuit applications. 1.9 buffered output to drive external loads without using an exte rnal operational amplifier, dac channels have embedded output buffers which can be enabled and disabled depending on the user application. when the dac output is not buffered, and there is a load in the user application circuit, the voltage output will be lower than the desired volt age. enabling the buffer, the voltage output and the voltage desired are similar. figure 10. non buffered channel voltage (with and without load) triangular waveform pattern waveform (offset) result waveform ai18308 ai18309 dac dac_channel_1 dor = 0xfff ? dac dac_channel_1 dor = 0xfff ? 3.3v r = 5.1k gnd 1.2 v 1 . 2 v 3.3 v 3.3 v 3 . 3 v
dac main features AN3126 14/24 doc id16895 rev 2 figure 11. buffered channel voltage (with and without load) ai18310 dac dac_channel_1 dor = 0xfff ? dac dac_channel_1 dor = 0xfff ? 3.3v r = 5.1k gnd 3.3 v 3 . 3 v 3.3 v 3.3 v 3 . 3 v
doc id16895 rev 2 15/24 AN3126 application examples 23 2 application examples 2.1 using the dac to ge nerate a sine waveform 2.1.1 description this example describes step by step how to generate a sine waveform. a sine waveform is also called a sine tone with a single frequency, it is known as a pure tone or sinus tone. the sine tones are traditionally used are stimuli in determining the various responses of the auditory system. 2.1.2 digital sine wavef orm pattern preparation to prepare the digital pattern of the waveform, we have to do some mathematics. our objective is to have 10 digital pattern da t a (samples) of a sine wave form which varies from 0 to 2*pi. figure 12. sine wave model samples the sampling step is (2*pi)/ n s (number of samples). the result value of sin(x) is between -1 and 1, we have to recalibrate it to have a positive sinewave with samples varying between 0 and 0xfff (which correspond, the range from 0 v to 3.3 v). y sinedigital x () x 2  n s ------    1 + sin   0xfff 1 + () 2 -------------------------------- -   = digital inputs are converted to output volt ages on a linear conversion between 0 and v ref+ . the analog output voltages on each dac chan nel pin are determined by the following equation: dac output v ref dor dac_maxdigitalvalue ---------------------------------------------------------- - = ai18311 0 1000 2000 3000 4000 5000 0 2468 1 3579 y sinedigital 0 0.805 1.611 2.147 3.223 4.029 y sineanalog (volt)
application examples AN3126 16/24 doc id16895 rev 2 note: for right-aligned 12-bit reso lution: dac_maxdigitalvalue = 0xfff for right-aligned 8-bit resoluti on: dac_maxdigitalvalue = 0xff so the analog sine waveform y sineanalog can be determined by the following equation y sineanalog x () 3.3volt y sinedigital x () 0xfff 1 + ------------------------------------ - = the table is saved in the memory and transferre d by the dma, the transfer is triggered by the same timer that triggers the dac 2.1.3 fixing the sine wave frequency to fix the frequency of the sinewave signal, you have to set the frequency of the timer trigger output. the frequency of the produced sine wave is f sinewave f timertrgo n s ----------------------------- - = so, if timx_trgo is 1 mhz, the frequen cy of the dac sine wave is 10 khz. note: to have a high quality sine wave curve, it is r ecommended to use a high number of samples n s (the difference can be appreciated by comparing figure 13 with figure 14 ). table 4. digital and analog sample values of the sine wave sample (x) digital sample value y sinedigital (x) analog sample value (volt) y sineanalog (x) 0 2048 1.650 1 3251 2.620 2 3995 3.219 3 3996 3.220 4 3253 2.622 5 2051 1.653 6 847 0.682 7 101 0.081 8 98 0.079 9 839 0.676
doc id16895 rev 2 17/24 AN3126 application examples 23 figure 13. sine wave generated with n s = 10 figure 14. sine wave generated with n s = 255 ai18312 0 1 2 3 4 y sineanalog (volt) time ai18313 0 1000 2000 3000 4000 5000 0 51 102 153 204 y sinedigital 0 0.805 1.611 2.147 3.223 4.029 y sineanalog (volt) 255 time
application examples AN3126 18/24 doc id16895 rev 2 2.2 using the dac to implem ent an audio wave player 2.2.1 description the purpose of this application demo is to pr ovide an audio player solution for the stm32 microcontroller for playing .wav files. the a pproach is optimized to use a minimum number of external components, and offers the flexibilit y for end-users to use their own .wav files. the audio files are provided to the stm32 from a microsd memory card. figure 15. flow of data from micros d flash memory to external speakers the audio wave player demonstration described in this section is a part of the stm32100b-eval demonstration firmware. you can download this firmware and the associated user manual (um0891) from the stmicroelectronics website www.st.com . ai18314 tim6 dac dma cpu spi ram .wav
doc id16895 rev 2 19/24 AN3126 application examples 23 2.2.2 audio wave file specifications this application assumes that the .wav f ile to be played has the following format: ? audio format: pcm (an uncompressed wave data format in which each value represents the amplitude of the signal at the time of sampling) ? sample rate: may be 8000, 11025, 22050 or 44100 hz ? bits per sample: 8-bit (audio sample data values are in the range [0-255]) ? number of channels: 1 (mono) 2.2.3 . wav file format the .wav file format is a subset of the reso urce interchange file format (riff) specification used for the stora ge of multimedia files. a riff f ile starts with a file header followed by a sequence of data chunks. a .wav file is often just a riff file with a single "wave" chunk consisting of two sub-chunks: 1. a fmt chunk specifying the data format 2. a data chunk containing the actual sample data. the wave file format starts with the riff header: it indicates the file length. next, the fmt chunk describes th e sample format, it contains information about: format of the wave audio : (pcm/...), number of channels (mono/stereo), sample rate (number of samples per seconds : e.g., 22050), and the samp le data size (e.g. 8bit/16bit). finally, the data chunk contains the sample data. 2.3 audio wave player implementation the audio wave player application is based on the spi, dma, tim6, and dac peripherals. at start up, the application first uses the spi to interface with the microsd card and parses its content, using the dosfs file system, lookin g for available .wav file s in the user folder. once a valid .wav file is found , it is read back though the spi, and the data are transferred using the cpu to a buffer array located in the ram. the dma is used to transfer data from ram to dac peripheral. tim6 is used to trigger the dac whic h will convert the audio digital data to an analog waveform. before the audio data can be played, the header of the wav file is parsed so that the sampling rate of the data and its length can be determined. the task of reproducing audio is achieved by using sampled data (data contained in the .wav file) to update the value of the dac output, this data is coded in 8 bits (with values from 0 to 255), the dac channel 1 is triggered by tim6 at regu lar interval specified by the sample rate of the .wav file header. the .wav files are read from the microsd memory using a dosfs file system. in the demo code, code files handling the waveplayer demo are: waveplayer.c waveplayer.h the wave player demo is called using waveplayermenu_start() function which has the flowchart shown in figure 16 .
application examples AN3126 20/24 doc id16895 rev 2 figure 16. wave player flowchart (*) when dma is transferring data from one ram buffer, cpu is transferring data from the microsd flash memory to the other ram buffer. ai18315 enable dma,tim6,dac clocks wavepla y er _ menustart () config dac channel 1 to be triggered by tim6 trgo config dma ch3 to transfer 512 bytes from wavbuffer1 to dac ch1 8bit dhr register enable dac channel 1 and dma connection enable dac channel 1 output parse the .wav file to check if it is a valid file and get all needed information from the .wav header. display error if .wav file status ok connect tim6 trgo to its update event enable tim6 (start the transfer from ram to dac) enable dma channel3 configure the tim6 frequency to have the correct .wav sample rate initialize wavedatalength with .wav file audible data size if wavedatalength!= 0 read 512 next bytes from the .wav file and save them in wavbuffer2 (*) if dma transfer from wavbuffer1 to dac ch1 is completed (*) clear dma channel3 flag decrement the wavedatalength by 512 and if wavedatalength < 512 then wavedatalength = 0 disable dma , config dma to transfer 512 bytes from wavbuffer2 to dac ch1 8bit dhr register, and enable dma read 512 next bytes from the .wav file and save them in wavbuffer1 (*) if dma transfer from wavbuffer2 to dac ch1 is completed (*) decrement the wavedatalength by 512 and if wavedatalength < 512 then wavedatalength = 0 clear dma channel3 flag disable dma, configure dma transfer 512 bytes from wavbuffer1 to dac ch1 8bit dhr register, and enable dma disable dma exit yes yes yes no no no
doc id16895 rev 2 21/24 AN3126 application examples 23 in this application, coprocessing is mandatory to permit a simultaneous wave read (from the external memory source) and write (in the dac register). figure 17. cpu and dma activities during wave playing process ai18316 transfer 512 bytes data from wavbuffur_1 to dac (transfer triggered by tim6_trgo) idle (no activity) cpu dma tim6_trgo . . . . . . . . . . . . . . . . . . . . . . . . . . 512 pulses transfer 512 byte data from microsd memory in wavbuffer_2 decrement the wavedatalength counter and dma reconfiguration transfer 512 bytes data from wavbuffur_2 to dac (transfer triggered by tim6_trgo) transfer 512 byte data from microsd memory in wavbuffer_1 idle (no activity) . . . . . . . . . . . . . . . . . . . . . . . . . . 512 pulses . . . . . . decrement the wavedatalength counter and dma reconfiguration
conclusion AN3126 22/24 doc id16895 rev 2 3 conclusion this application note and in particular the examples given in section 2 have been provided to help you get familiar with the dac?s main features. the first example (in section 2.1 ) shows how to generate an analog waveform, using the example of a sine waveform. the second example (in section 2.2 ) offers a straightforward and flexible solution for using the stm32, to pl ay .wav files, stored in an spi microsd flash memory. you can use these examples as starting poin ts for developing your own solution using stm32 microcontrollers.
doc id16895 rev 2 23/24 AN3126 revision history 23 4 revision history table 5. document revision history date revision changes 28-may-2010 1 initial release. 16-apr-2015 2 updated introduction , section 1.3: dual channel mode and section 3: conclusion . updated formulas in section 2.1.2: digital sine waveform pattern preparation . updated figure 2: stm32f100x dac trigger channels and figure 5: pseudo random code generator embedded in the dac . added table 1: applicable products and table 2: dac configurations for stm32 microcontrollers . added section 1.1: overview , and note in section 1.3: dual channel mode .
AN3126 24/24 doc id16895 rev 2 important notice ? please read carefully stmicroelectronics nv and its subsidiaries (?st?) reserve the right to make changes, corrections, enhancements, modifications, and improvements to st products and/or to this document at any time without notice. purchasers should obtain the latest relevant in formation on st products before placing orders. st products are sold pursuant to st?s terms and conditions of sale in place at the time of o rder acknowledgement. purchasers are solely responsible for the choice, selection, and use of st products and st assumes no liability for application assistance or the design of purchasers? products. no license, express or implied, to any intellectual property right is granted by st herein. resale of st products with provisions different from the information set forth herein shall void any warranty granted by st for such product. st and the st logo are trademarks of st. all other product or service names are the property of their respective owners. information in this document supersedes and replaces information previously supplied in any prior versions of this document. ? 2015 stmicroelectronics ? all rights reserved


▲Up To Search▲   

 
Price & Availability of AN3126

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X